import inspect
from functools import wraps

def check(fn):

    @wraps(fn)
    def warpper(*args, **kwargs):

        sig = inspect.signature(fn)
        parameter = sig.parameters  # 有序字典（在这里是只读的有序字典）
        # 位置参数检查
        print(parameter)
        parameter_list = list(parameter.keys())
        print(parameter_list)
        for index, v in enumerate(args):
            key = parameter_list[index]
            if isinstance(v, parameter[key].annotation):
                print(f"{v}{' is type '}{parameter[key].annotation}")
            else:
                print(f"{v}{' not is type '}{parameter[key].annotation}")
                return "xxx"

        # 关键字参数检查
        for k, v in kwargs.items():
            if isinstance(v, parameter[k].annotation):
                print(f"{v}{' is type '}{parameter[k].annotation}")
            else:
                print(f"{v}{' not is type '}{parameter[k].annotation}")
                return None

        ret = fn(*args, **kwargs)
        return ret
    return warpper

@check
def add(y, e: int, x: int=1):
    return x + y

print(add(2, "3"))
